<%@ page contentType="text/html;charset=UTF-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <!--[if lt IE 9]>
    <script type="text/javascript" src="lib/html5shiv.js"></script>
    <script type="text/javascript" src="lib/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css"/>
    <link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css"/>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="static/element/index.css">
    <%--    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">--%>
    <!--[if IE 6]>
    <script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js"></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title></title>
    <style>
        .fail .layui-layer-content {
            background-color: brown;
            color: #eee;
            width: 480px;
            height: 30px;
            text-align: center;
        }

        .succeed .layui-layer-content {
            background-color: #0061A8;
            color: #eee;
            width: 480px;
            height: 30px;
            text-align: center;
        }

        * {
            padding: 0;
            margin: 0;
        }

        html {
            overflow-y: hidden;
        }

        body, html {
            width: 100%;
            height: 100%;
        }

        body {
            display: flex;
            flex-flow: column;
        }

        .fheader {
            height: 1%;
            min-height: 50px;
        }

        .fsection {
            /*flex-grow: 1;*/
            display: flex;
            flex-flow: row;
            margin-top: 10px;
            /*height: 99%;*/
            min-height: 0;
        }

        .farticle {
            flex: 1;
            padding: 1px;
        }

        .el-table__body tr:hover > td {
            background-color: #DFDFDF !important;
            cursor: default
        }
    </style>
</head>
<body>
<div id="app">
    <div class="fheader" style="padding: 0;margin: 0 ">
        <nav class="breadcrumb" style="height: 100%; padding: 0;margin-top: 8px ">
            <div class="l" style="margin-left: 20px; padding-top: 5px"> 查询内容：
                <el-autocomplete
                        class="inline-input"
                        v-model="state2"
                        :fetch-suggestions="querySearch"
                        placeholder="请输入内容"
                        clearable
                        @select="handleSelect">
                </el-autocomplete>
                <a class="btn btn-warning radius" style="line-height:1.6em; margin-left: 8px" @click="fReset()" title="重置">重置</a>
                <button style="margin-left: 8px;" @click="fSearchKh()" class="btn btn-success radius" name=""><i class="Hui-iconfont">&#xe665;</i>按卡号查询</button>
<%--                <el-button type="warning" @click="fRgxf('人工消费')" :disabled="rightRgxf" size="mini" style="width: 100px">人工消费</el-button>--%>
            </div>
        </nav>
    </div>
    <div class="fsection">
        <div class="farticle">
            <div style="height: 100%; width: 100%; overflow: scroll; float: left; overflow-x: hidden;">
                <el-table :data="tableData" stripe border style="width: 100%" :height="tableHeightL" empty-text="没有数据" :header-cell-style="tableHeaderCellStyleL" :cell-style="tableCellStyleL">
                    <el-table-column prop="VALUE01" label="姓名" width="80"></el-table-column>
                    <el-table-column prop="VALUE02" label="工号" width="85"></el-table-column>
                    <el-table-column prop="VALUE03" label="部门"></el-table-column>
                    <el-table-column prop="VALUE04" label="人员类别" width="80"></el-table-column>
                    <el-table-column prop="VALUE05" label="消费类别" width="100"></el-table-column>
                    <el-table-column prop="VALUE08" label="电话号码" width="105"></el-table-column>
                    <el-table-column prop="VALUE18" label="余额" width="80"></el-table-column>
                    <el-table-column prop="VALUE19" label="卡号" width="120"></el-table-column>
                    <el-table-column label="操作" width="500" >
                        <template slot-scope="scope">
                            <el-button v-if="scope.row.VALUE17 === '正常'" type="primary" @click="fGsJg('挂失',scope.row)" size="mini" style="width: 60px; padding-left: 0;padding-right: 0; margin: 2px;">卡挂失</el-button>
                            <el-button v-else type="primary" @click="fGsJg('解挂',scope.row)" size="mini" style="width: 60px;padding-left: 0;padding-right: 0; margin: 2px; color: yellow">卡解挂</el-button>
                            <el-button type="warning" @click="fCz('充值',scope.row)" :disabled="rightCz" size="mini" style="width: 50px; margin: 2px;">充值</el-button>
                            <el-button type="warning" @click="fTk('退款',scope.row)" :disabled="rightTk" size="mini" style="width: 50px; margin: 2px;">退款</el-button>
                            <el-button type="warning" @click="fChong('冲正',scope.row)" :disabled="rightChong" size="mini" style="width: 50px; margin: 2px;">冲正</el-button>
                        </template>
                    </el-table-column>
                </el-table>
            </div>
        </div>
    </div>
</div>

<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="static/axios.min.js"></script>
<script type="text/javascript" src="./static/vue"></script>
<script src="static/element/index.js"></script>
<script type="text/javascript">
    let vm = new Vue({
        el: '#app',
        data: {
            state2: '',
            restaurants: [],
            tableHeightL: 0,
            ryzh: '',   //--人员帐号
            cxfs: '',

            ii_page: 1,   //--上一页下一页的计数器
            ii_row: 20,   //--每页显示的记录数
            iiCount: 0,
            is_search: '',
            tableTree: [],      //--部门表
            tableData: [],      //--具体人员信息表
            tableRylb: [],      //--人员类别
            tableXflb: [],      //--消费类别
            rightKk: true,
            rightGs: true,
            rightJg: true,
            rightDsbk: true,
            rightCz: true,
            rightTk: true,
            rightChong: true,
            rightRgxf: true,
        },
        methods: {
            fReset() {
                this.ryzh = ''
                this.czfs = ''
                this.state2 = ''
            },

            //--依据人员的帐号去查询人员的信息
            fGetinfoEmp() {
                let ls_opid = "${sessionOpid}";
                let self = this
                let params = new URLSearchParams();
                params.append('CMD', "ZS");
                params.append('VALUE01', this.ryzh);
                params.append('VALUE02', this.cxfs);
                params.append('VALUE03', ls_opid);
                axios.post('/f_wscl/com2', params)
                    .then(function (res) {
                        let {db1, db2, db3} = res.data
                        if (db3[0].VALUE01 === 'ZZ01') {
                            self.tableData = []
                            layer.msg('<span style="font-size:24px; line-height: 30px">' + db3[0].VALUE02 + '</span>', {time: 2000, skin: 'fail'});
                        } else {
                            self.state2 = ''
                            self.tableData = db1
                            self.rightKk = db3[0].VALUE02 !== "false";
                            self.rightGs = db3[1].VALUE02 !== "false";
                            self.rightJg = db3[2].VALUE02 !== "false";
                            self.rightDsbk = db3[3].VALUE02 !== "false";
                            self.rightCz = db3[4].VALUE02 !== "false";
                            self.rightTk = db3[5].VALUE02 !== "false";
                            self.rightChong = db3[6].VALUE02 !== "false";
                            self.rightRgxf = db3[7].VALUE02 !== "false";
                        }
                    })
                    .catch(function (error) {
                        layer.msg('网络异常错误', {icon: 1, time: 1000});
                    });
            },

            //--按照输入的卡号进行查询
            fSearchKh() {
                let self = this
                layer.prompt({
                    formType: 0,
                    value: '',
                    title: '请读卡',
                    maxlength: 15,
                    area: ['300px', '120px'] //自定义文本域宽高
                }, function (value, index, elem) {
                    if (isNaN(value)) {
                        layer.msg("请读出数字卡号", {icon: 0, time: 2000});
                        return;
                    }
                    self.ryzh = value
                    self.cxfs = 'KH'
                    self.fGetinfoEmp()
                    layer.close(index);
                }, function () {
                });
            },

            //--按照输入的卡号进行查询
            fSearchQu() {
                let self = this
                layer.prompt({
                    formType: 0,
                    value: '',
                    title: '请读卡',
                    maxlength: 15,
                    area: ['300px', '120px'] //自定义文本域宽高
                }, function (value, index, elem) {
                    if (isNaN(value)) {
                        layer.msg("请读出数字卡号", {icon: 0, time: 2000});
                        return;
                    }
                    let params = new URLSearchParams();
                    params.append('CMD', "BI");
                    params.append('VALUE01', value);
                    axios.post('/f_wscl/com2', params)
                        .then(function (res) {
                            let {db1} = res.data
                            if (db1[0].VALUE01 === 'ZZ01') {
                                layer.msg("<span style='font-size:24px; line-height: 30px'>" + db1[0].VALUE02 + "</span>", {time: 2000, skin: 'fail'}, function () {
                                    layer.close(index);
                                });
                            } else if (db1[0].VALUE01 === 'ZZ00') {
                                layer.msg("<span style='font-size:24px; line-height: 30px'>" + db1[0].VALUE02 + "</span>", {time: 2000, skin: 'succeed'}, function () {
                                    layer.close(index);
                                });
                            }
                        })
                        .catch(function (error) {
                            layer.msg('<span style="font-size:24px; line-height: 30px">网络异常错误!</span>', {time: 1500, skin: 'fail'});
                        })
                        .finally(function () {
                        });

                }, function () {
                });
            },

            //--挂失解挂
            fGsJg(title, obj) {
                if (obj.VALUE17.toString() === '冻结') {
                    layer.msg('<span style="font-size:24px; line-height: 30px">该人员已被冻结，无法进行相关操作!</span>', {time: 1500, skin: 'fail'});
                    return
                }

                let ls_opid = "${sessionOpid}";
                let self = this
                layer.open({
                    type: 2,
                    area: ['800px', '600px'],
                    fix: false, //不固定
                    maxmin: false,
                    shade: 0.4,
                    title: title,
                    content: ['w_zxkj_cardgs.jsp', 'no'],
                    success: function (layero, index) {
                        let body = layer.getChildFrame('body', index);//少了这个是不能从父页面向子页面传值的
                        const iframeWin = window[layero.find('iframe')[0]['name']];   //--通过将弹出的layer窗口中将vue中的函数在created周期中赋给windows，
                                                                                      //--然后用本变量进行访问，由此可以达到操作弹出layer界面的功能，该功能重要中的重要几句是layer的seccess回调，需要加强理解
                        iframeWin.fInit({
                            "opid": ls_opid,
                            "btnText": title,
                            "tableEmp": obj,
                            "tableTree": self.tableTree,
                            "tableRylb": self.tableRylb,
                            "tableXflb": self.tableXflb
                        })
                    },
                });
            },

            //--充值
            fCz(title, obj) {
                if (obj.VALUE17.toString() === '冻结') {
                    layer.msg('<span style="font-size:24px; line-height: 30px">该人员已被冻结，无法进行相关操作!</span>', {time: 1500, skin: 'fail'});
                    return
                }

                let ls_opid = "${sessionOpid}";
                let self = this
                let params = new URLSearchParams();
                params.append('CMD', "ZS");
                params.append('VALUE01', obj.VALUE10);
                params.append('VALUE02', 'ZH');
                axios.post('/f_wscl/com2', params)
                    .then(function (res) {
                        let {db1} = res.data
                        layer.open({
                            type: 2,
                            area: ['800px', '610px'],
                            fix: false, //不固定
                            maxmin: false,
                            shade: 0.4,
                            title: title,
                            content: ['w_zxkj_cardcz.jsp', 'no'],
                            success: function (layero, index) {
                                const iframeWin = window[layero.find('iframe')[0]['name']];   //--通过将弹出的layer窗口中将vue中的函数在created周期中赋给windows，
                                iframeWin.fInit({
                                    "opid": ls_opid,
                                    "btnText": title,
                                    "tableEmp": db1[0],
                                    "tableTree": self.tableTree,
                                    "tableRylb": self.tableRylb,
                                    "tableXflb": self.tableXflb
                                })
                            },
                        });
                    })
                    .catch(function (error) {
                        layer.msg('网络异常错误', {icon: 1, time: 1000});
                    });
            },

            //--人工消费
            fRgxf(title, obj) {
                let self = this
                layer.open({
                    type: 2,
                    area: ['800px', '670'],
                    fix: false, //不固定
                    maxmin: false,
                    shade: 0.4,
                    title: title,
                    content: ['w_zxkj_cardrgxf.jsp', 'no'],
                    success: function (layero, index) {
                        const iframeWin = window[layero.find('iframe')[0]['name']];   //--通过将弹出的layer窗口中将vue中的函数在created周期中赋给windows，
                        iframeWin.fInit({
                            "tableTree": self.tableTree,
                            "tableRylb": self.tableRylb,
                            "tableXflb": self.tableXflb,
                            "restaurants": self.restaurants
                        })
                    },
                });
            },

            //--退款
            fTk(title, obj) {
                let self = this
                let ls_opid = "${sessionOpid}";
                let params = new URLSearchParams();
                params.append('CMD', "ZS");
                params.append('VALUE01', obj.VALUE10);
                params.append('VALUE02', 'ZH');
                axios.post('/f_wscl/com2', params)
                    .then(function (res) {
                        let {db1} = res.data
                        layer.open({
                            type: 2,
                            area: ['800px', '670px'],
                            fix: false, //不固定
                            maxmin: false,
                            shade: 0.4,
                            title: title,
                            content: ['w_zxkj_cardtk.jsp', 'no'],
                            success: function (layero, index) {
                                const iframeWin = window[layero.find('iframe')[0]['name']];   //--通过将弹出的layer窗口中将vue中的函数在created周期中赋给windows，
                                iframeWin.fInit({
                                    "opid": ls_opid,
                                    "btnText": title,
                                    "tableEmp": db1[0],
                                    "tableTree": self.tableTree,
                                    "tableRylb": self.tableRylb,
                                    "tableXflb": self.tableXflb
                                })
                            },
                        });
                    })
                    .catch(function (error) {
                        layer.msg('网络异常错误', {icon: 1, time: 1000});
                    });
            },

            //--冲正
            fChong(title, obj) {
                if (obj.VALUE17.toString() === '冻结') {
                    layer.msg('<span style="font-size:24px; line-height: 30px">该人员已被冻结，无法进行相关操作!</span>', {time: 1500, skin: 'fail'});
                    return
                }
                //--先去获取当天的消费记录
                let params = new URLSearchParams();
                params.append('CMD', "ZX");
                params.append('VALUE01', obj.VALUE10);
                params.append('VALUE02', this.cxfs);
                axios.post('/f_wscl/com2', params)
                    .then(function (res) {
                        let {db1} = res.data
                        if (db1[0].VALUE01 === 'ZZ01') {
                            layer.msg("<span style='font-size:24px; line-height: 30px'>" + db1[0].VALUE02 + "</span>", {time: 2000, skin: 'fail'});
                        } else {
                            layer.open({
                                type: 2,
                                area: ['800px', '500px'],
                                fix: false, //不固定
                                maxmin: false,
                                shade: 0.4,
                                title: title,
                                content: ['w_zxkj_cardchong.jsp', 'no'],
                                success: function (layero, index) {
                                    const iframeWin = window[layero.find('iframe')[0]['name']];   //--通过将弹出的layer窗口中将vue中的函数在created周期中赋给windows，
                                    iframeWin.fInit({
                                        "btnText": title,
                                        "tableLs": db1,
                                    })
                                },
                            })
                        }
                    })
                    .catch(function (error) {
                        layer.msg('网络异常错误', {icon: 1, time: 1000});
                    });
            },

            querySearch(queryString, cb) {
                let restaurants = this.restaurants;
                let results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants;
                // 调用 callback 返回建议列表的数据
                cb(results);
            },

            createFilter(queryString) {
                return (restaurants) => {
                    return (restaurants.value.toLowerCase().indexOf(queryString.toLowerCase()) >= 0);
                };
            },

            //--输入框选择后的人员帐号
            handleSelect(item) {
                this.ryzh = item.address
                this.cxfs = 'ZH'
                this.fGetinfoEmp()
            },

            tableHeaderCellStyleL({row, column, rowIndex, columnIndex}) {
                let cellStyle1;

                cellStyle1 = "color: #fff;" +
                    "background:#4F4F4F;" +
                    "height:40px;" +
                    "text-align:center;" +
                    "font-size:12px"

                return cellStyle1
            },

            tableCellStyleL({row, column, rowIndex, columnIndex}) {
                let cellStyle1;

                if (columnIndex === 8){
                    cellStyle1 = "text-align:left;" +
                        "padding:8px 1px 8px;" +
                        "font-size:12px;"
                }
                else {
                    cellStyle1 = "text-align:center;" +
                        "padding:8px 1px 8px;" +
                        "font-size:12px"
                }
                return cellStyle1;
            },

            //--查询出输入框的基础检索数据
            fInit() {
                let ls_opid = "${sessionOpid}";
                let self = this
                let params = new URLSearchParams();
                params.append('CMD', "ZO");
                params.append('VALUE01', ls_opid);

                axios.post('/f_wscl/com2', params)
                    .then(function (res) {
                        let {db1, db2, db3, db4, db5} = res.data
                        self.tableTree = db1
                        self.tableRylb = db2
                        self.tableXflb = db3
                        self.restaurants = JSON.parse(JSON.stringify(db4).replace(/VALUE01/g, "value")
                            .replace(/VALUE02/g, "address"));
                        self.rightKk = db5[0].VALUE02 !== "false";
                        self.rightGs = db5[1].VALUE02 !== "false";
                        self.rightJg = db5[2].VALUE02 !== "false";
                        self.rightDsbk = db5[3].VALUE02 !== "false";
                        self.rightCz = db5[4].VALUE02 !== "false";
                        self.rightTk = db5[5].VALUE02 !== "false";
                        self.rightChong = db5[6].VALUE02 !== "false";
                        self.rightRgxf = db5[7].VALUE02 !== "false";
                    })
                    .catch(function (error) {
                        layer.msg('<span style="font-size:24px; line-height: 30px">网络异常错误!</span>', {time: 2000, skin: 'fail'});
                    });
            },

        },
        mounted() {
            window.fGetinfoEmp = this.fGetinfoEmp;
        },
        created() {
            let windowHeight = document.documentElement.clientHeight || document.body.clientHeight;
            this.tableHeightL = windowHeight - 85;
            this.fInit()
        }
    });

</script>

</body>
</html>
